home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MOR55SRC.ZIP / MORIA / SOURCE / WIZARD.C < prev   
C/C++ Source or Header  |  1992-12-07  |  9KB  |  418 lines

  1. /* source/wizard.c: Version history and info, and wizard mode debugging aids.
  2.  
  3.    Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  4.  
  5.    This software may be copied and distributed for educational, research, and
  6.    not for profit purposes provided that this copyright and statement are
  7.    included in all such copies. */
  8.  
  9. #ifdef __TURBOC__
  10. #include    <stdio.h>
  11. #include    <stdlib.h>
  12. #endif /* __TURBOC__ */
  13.  
  14. #include "config.h"
  15. #include "constant.h"
  16. #include "types.h"
  17. #include "externs.h"
  18.  
  19. #ifdef USG
  20. #ifndef ATARIST_MWC
  21. #include <string.h>
  22. #endif
  23. #else
  24. #include <strings.h>
  25. #endif
  26.  
  27. #ifdef ATARIST_TC
  28. /* Include this to get prototypes for standard library functions.  */
  29. #include <stdlib.h>
  30. #endif
  31.  
  32. long atol();
  33.  
  34. /* Light up the dungeon                    -RAK-    */
  35. void wizard_light()
  36. {
  37.   register cave_type *c_ptr;
  38.   register int k, l, i, j;
  39.   int flag;
  40.  
  41.   if (cave[char_row][char_col].pl)
  42.     flag = FALSE;
  43.   else
  44.     flag = TRUE;
  45.   for (i = 0; i < cur_height; i++)
  46.     for (j = 0; j < cur_width; j++)
  47.       if (cave[i][j].fval <= MAX_CAVE_FLOOR)
  48.     for (k = i-1; k <= i+1; k++)
  49.       for (l = j-1; l <= j+1; l++)
  50.         {
  51.           c_ptr = &cave[k][l];
  52.           c_ptr->pl = flag;
  53.           if (!flag)
  54.         c_ptr->fm = FALSE;
  55.         }
  56.   prt_map();
  57. }
  58.  
  59.  
  60. /* Wizard routine for gaining on stats            -RAK-    */
  61. void change_character()
  62. {
  63.   register int tmp_val;
  64.   register int32 tmp_lval;
  65.   int8u *a_ptr;
  66.   vtype tmp_str;
  67.   register struct misc *m_ptr;
  68.  
  69.   a_ptr = py.stats.max_stat;
  70.   prt("(3 - 118) Strength     = ", 0, 0);
  71.   if (get_string(tmp_str, 0, 25, 3))
  72.     {
  73.       tmp_val = atoi(tmp_str);
  74.       if ((tmp_val > 2) && (tmp_val < 119))
  75.     {
  76.       a_ptr[A_STR] = tmp_val;
  77.       (void) res_stat(A_STR);
  78.     }
  79.     }
  80.   else
  81.     return;
  82.  
  83.   prt("(3 - 118) Intelligence = ", 0, 0);
  84.   if (get_string(tmp_str, 0, 25, 3))
  85.     {
  86.       tmp_val = atoi(tmp_str);
  87.       if ((tmp_val > 2) && (tmp_val < 119))
  88.     {
  89.       a_ptr[A_INT] = tmp_val;
  90.       (void) res_stat(A_INT);
  91.     }
  92.     }
  93.   else
  94.     return;
  95.  
  96.   prt("(3 - 118) Wisdom       = ", 0, 0);
  97.   if (get_string(tmp_str, 0, 25, 3))
  98.     {
  99.       tmp_val = atoi(tmp_str);
  100.       if ((tmp_val > 2) && (tmp_val < 119))
  101.     {
  102.       a_ptr[A_WIS] = tmp_val;
  103.       (void) res_stat(A_WIS);
  104.     }
  105.     }
  106.   else
  107.     return;
  108.  
  109.   prt("(3 - 118) Dexterity    = ", 0, 0);
  110.   if (get_string(tmp_str, 0, 25, 3))
  111.     {
  112.       tmp_val = atoi(tmp_str);
  113.       if ((tmp_val > 2) && (tmp_val < 119))
  114.     {
  115.       a_ptr[A_DEX] = tmp_val;
  116.       (void) res_stat(A_DEX);
  117.     }
  118.     }
  119.   else
  120.     return;
  121.  
  122.   prt("(3 - 118) Constitution = ", 0, 0);
  123.   if (get_string(tmp_str, 0, 25, 3))
  124.     {
  125.       tmp_val = atoi(tmp_str);
  126.       if ((tmp_val > 2) && (tmp_val < 119))
  127.     {
  128.       a_ptr[A_CON] = tmp_val;
  129.       (void) res_stat(A_CON);
  130.     }
  131.     }
  132.   else
  133.     return;
  134.  
  135.   prt("(3 - 118) Charisma     = ", 0, 0);
  136.   if (get_string(tmp_str, 0, 25, 3))
  137.     {
  138.       tmp_val = atoi(tmp_str);
  139.       if ((tmp_val > 2) && (tmp_val < 119))
  140.     {
  141.       a_ptr[A_CHR] = tmp_val;
  142.       (void) res_stat(A_CHR);
  143.     }
  144.     }
  145.   else
  146.     return;
  147.  
  148.   m_ptr = &py.misc;
  149.   prt("(1 - 32767) Hit points = ", 0, 0);
  150.   if (get_string(tmp_str, 0, 25, 5))
  151.     {
  152.       tmp_val = atoi(tmp_str);
  153.       if ((tmp_val > 0) && (tmp_val <= MAX_SHORT))
  154.     {
  155.       m_ptr->mhp  = tmp_val;
  156.       m_ptr->chp  = tmp_val;
  157.       m_ptr->chp_frac = 0;
  158.       prt_mhp();
  159.       prt_chp();
  160.     }
  161.     }
  162.   else
  163.     return;
  164.  
  165.   prt("(0 - 32767) Mana       = ", 0, 0);
  166.   if (get_string(tmp_str, 0, 25, 5))
  167.     {
  168.       tmp_val = atoi(tmp_str);
  169.       if ((tmp_val > -1) && (tmp_val <= MAX_SHORT) && (*tmp_str != '\0'))
  170.     {
  171.       m_ptr->mana  = tmp_val;
  172.       m_ptr->cmana = tmp_val;
  173.       m_ptr->cmana_frac = 0;
  174.       prt_cmana();
  175.     }
  176.     }
  177.   else
  178.     return;
  179.  
  180.   (void) sprintf(tmp_str, "Current=%ld  Gold = ", m_ptr->au);
  181.   tmp_val = strlen(tmp_str);
  182.   prt(tmp_str, 0, 0);
  183.   if (get_string(tmp_str, 0, tmp_val, 7))
  184.     {
  185.       tmp_lval = atol(tmp_str);
  186.       if (tmp_lval > -1 && (*tmp_str != '\0'))
  187.     {
  188.       m_ptr->au = tmp_lval;
  189.       prt_gold();
  190.     }
  191.     }
  192.   else
  193.     return;
  194.  
  195.   (void) sprintf(tmp_str, "Current=%d  (0-200) Searching = ", m_ptr->srh);
  196.   tmp_val = strlen(tmp_str);
  197.   prt(tmp_str, 0, 0);
  198.   if (get_string(tmp_str, 0, tmp_val, 3))
  199.     {
  200.       tmp_val = atoi(tmp_str);
  201.       if ((tmp_val > -1) && (tmp_val < 201) && (*tmp_str != '\0'))
  202.     m_ptr->srh  = tmp_val;
  203.     }
  204.   else
  205.     return;
  206.  
  207.   (void) sprintf(tmp_str, "Current=%d  (-1-18) Stealth = ", m_ptr->stl);
  208.   tmp_val = strlen(tmp_str);
  209.   prt(tmp_str, 0, 0);
  210.   if (get_string(tmp_str, 0, tmp_val, 3))
  211.     {
  212.       tmp_val = atoi(tmp_str);
  213.       if ((tmp_val > -2) && (tmp_val < 19) && (*tmp_str != '\0'))
  214.     m_ptr->stl  = tmp_val;
  215.     }
  216.   else
  217.     return;
  218.  
  219.   (void) sprintf(tmp_str, "Current=%d  (0-200) Disarming = ", m_ptr->disarm);
  220.   tmp_val = strlen(tmp_str);
  221.   prt(tmp_str, 0, 0);
  222.   if (get_string(tmp_str, 0, tmp_val, 3))
  223.     {
  224.       tmp_val = atoi(tmp_str);
  225.       if ((tmp_val > -1) && (tmp_val < 201) && (*tmp_str != '\0'))
  226.     m_ptr->disarm = tmp_val;
  227.     }
  228.   else
  229.     return;
  230.  
  231.   (void) sprintf(tmp_str, "Current=%d  (0-100) Save = ", m_ptr->save);
  232.   tmp_val = strlen(tmp_str);
  233.   prt(tmp_str, 0, 0);
  234.   if (get_string(tmp_str, 0, tmp_val, 3))
  235.     {
  236.       tmp_val = atoi(tmp_str);
  237.       if ((tmp_val > -1) && (tmp_val < 201) && (*tmp_str != '\0'))
  238.     m_ptr->save = tmp_val;
  239.     }
  240.   else
  241.     return;
  242.  
  243.   (void) sprintf(tmp_str, "Current=%d  (0-200) Base to hit = ", m_ptr->bth);
  244.   tmp_val = strlen(tmp_str);
  245.   prt(tmp_str, 0, 0);
  246.   if (get_string(tmp_str, 0, tmp_val, 3))
  247.     {
  248.       tmp_val = atoi(tmp_str);
  249.       if ((tmp_val > -1) && (tmp_val < 201) && (*tmp_str != '\0'))
  250.     m_ptr->bth  = tmp_val;
  251.     }
  252.   else
  253.     return;
  254.  
  255.   (void) sprintf(tmp_str, "Current=%d  (0-200) Bows/Throwing = ",
  256.          m_ptr->bthb);
  257.   tmp_val = strlen(tmp_str);
  258.   prt(tmp_str, 0, 0);
  259.   if (get_string(tmp_str, 0, tmp_val, 3))
  260.     {
  261.       tmp_val = atoi(tmp_str);
  262.       if ((tmp_val > -1) && (tmp_val < 201) && (*tmp_str != '\0'))
  263.     m_ptr->bthb = tmp_val;
  264.     }
  265.   else
  266.     return;
  267.  
  268.   (void) sprintf(tmp_str, "Current=%d  Weight = ", m_ptr->wt);
  269.   tmp_val = strlen(tmp_str);
  270.   prt(tmp_str, 0, 0);
  271.   if (get_string(tmp_str, 0, tmp_val, 3))
  272.     {
  273.       tmp_val = atoi(tmp_str);
  274.       if (tmp_val > -1 && (*tmp_str != '\0'))
  275.     m_ptr->wt = tmp_val;
  276.     }
  277.   else
  278.     return;
  279.  
  280.   while(get_com("Alter speed? (+/-)", tmp_str))
  281.     {
  282.       if (*tmp_str == '+')
  283.     change_speed(-1);
  284.       else if (*tmp_str == '-')
  285.     change_speed(1);
  286.       else
  287.     break;
  288.       prt_speed();
  289.     }
  290. }
  291.  
  292.  
  293. /* Wizard routine for creating objects            -RAK-    */
  294. void wizard_create()
  295. {
  296.   register int tmp_val;
  297.   int32 tmp_lval;
  298.   vtype tmp_str;
  299.   register inven_type *i_ptr;
  300.   inven_type forge;
  301.   register cave_type *c_ptr;
  302.   char pattern[4];
  303.  
  304.   msg_print("Warning: This routine can cause a fatal error.");
  305.   i_ptr = &forge;
  306.   i_ptr->index = OBJ_WIZARD;
  307.   i_ptr->name2 = 0;
  308.   inscribe(i_ptr, "wizard item");
  309.   i_ptr->ident = ID_KNOWN2|ID_STOREBOUGHT;
  310.  
  311.   prt("Tval   : ", 0, 0);
  312.   if (!get_string(tmp_str, 0, 9, 3))
  313.     return;
  314.   tmp_val = atoi(tmp_str);
  315.   i_ptr->tval = tmp_val;
  316.  
  317.   prt("Tchar  : ", 0, 0);
  318.   if (!get_string(tmp_str, 0, 9, 1))
  319.     return;
  320.   i_ptr->tchar = tmp_str[0];
  321.  
  322.   prt("Subval : ", 0, 0);
  323.   if (!get_string(tmp_str, 0, 9, 5))
  324.     return;
  325.   tmp_val = atoi(tmp_str);
  326.   i_ptr->subval = tmp_val;
  327.  
  328.   prt("Weight : ", 0, 0);
  329.   if (!get_string(tmp_str, 0, 9, 5))
  330.     return;
  331.   tmp_val = atoi(tmp_str);
  332.   i_ptr->weight = tmp_val;
  333.  
  334.   prt("Number : ", 0, 0);
  335.   if (!get_string(tmp_str, 0, 9, 5))
  336.     return;
  337.   tmp_val = atoi(tmp_str);
  338.   i_ptr->number = tmp_val;
  339.  
  340.   prt("Damage (dice): ", 0, 0);
  341.   if (!get_string(tmp_str, 0, 15, 3))
  342.     return;
  343.   tmp_val = atoi(tmp_str);
  344.   i_ptr->damage[0] = tmp_val;
  345.  
  346.   prt("Damage (sides): ", 0, 0);
  347.   if (!get_string(tmp_str, 0, 16, 3))
  348.     return;
  349.   tmp_val = atoi(tmp_str);
  350.   i_ptr->damage[1] = tmp_val;
  351.  
  352.   prt("+To hit: ", 0, 0);
  353.   if (!get_string(tmp_str, 0, 9, 3))
  354.     return;
  355.   tmp_val = atoi(tmp_str);
  356.   i_ptr->tohit = tmp_val;
  357.  
  358.   prt("+To dam: ", 0, 0);
  359.   if (!get_string(tmp_str, 0, 9, 3))
  360.     return;
  361.   tmp_val = atoi(tmp_str);
  362.   i_ptr->todam = tmp_val;
  363.  
  364.   prt("AC     : ", 0, 0);
  365.   if (!get_string(tmp_str, 0, 9, 3))
  366.     return;
  367.   tmp_val = atoi(tmp_str);
  368.   i_ptr->ac = tmp_val;
  369.  
  370.   prt("+To AC : ", 0, 0);
  371.   if (!get_string(tmp_str, 0, 9, 3))
  372.     return;
  373.   tmp_val = atoi(tmp_str);
  374.   i_ptr->toac = tmp_val;
  375.  
  376.   prt("P1     : ", 0, 0);
  377.   if (!get_string(tmp_str, 0, 9, 5))
  378.     return;
  379.   tmp_val = atoi(tmp_str);
  380.   i_ptr->p1 = tmp_val;
  381.  
  382.   prt("Flags (In HEX): ", 0, 0);
  383.   if (!get_string(tmp_str, 0, 16, 8))
  384.     return;
  385.   /* can't be constant string, this causes problems with the GCC compiler
  386.      and some scanf routines */
  387.   (void) strcpy (pattern, "%lx");
  388.   (void) sscanf(tmp_str, pattern, &tmp_lval);
  389.   i_ptr->flags = tmp_lval;
  390.  
  391.   prt("Cost : ", 0, 0);
  392.   if (!get_string(tmp_str, 0, 9, 8))
  393.     return;
  394.   tmp_lval = atol(tmp_str);
  395.   i_ptr->cost = tmp_lval;
  396.  
  397.   prt("Level : ", 0, 0);
  398.   if (!get_string(tmp_str, 0, 10, 3))
  399.     return;
  400.   tmp_val = atoi(tmp_str);
  401.   i_ptr->level = tmp_val;
  402.  
  403.   if (get_check("Allocate?"))
  404.     {
  405.       /* delete object first if any, before call popt */
  406.       c_ptr = &cave[char_row][char_col];
  407.       if (c_ptr->tptr != 0)
  408.     (void) delete_object(char_row, char_col);
  409.  
  410.       tmp_val = popt();
  411.       t_list[tmp_val] = forge;
  412.       c_ptr->tptr = tmp_val;
  413.       msg_print("Allocated.");
  414.     }
  415.   else
  416.     msg_print("Aborted.");
  417. }
  418.